Skip to content

Make capacity growth parameters optional#668

Merged
tsmbland merged 3 commits intomainfrom
optional_growth_constraints
Mar 12, 2025
Merged

Make capacity growth parameters optional#668
tsmbland merged 3 commits intomainfrom
optional_growth_constraints

Conversation

@tsmbland
Copy link
Copy Markdown
Collaborator

@tsmbland tsmbland commented Mar 11, 2025

Description

This is a small change to make the MaxCapacityAddition, MaxCapacityGrowth and TotalCapacityLimit parameters optional.

I've found that many users just set these to very high values so that the constraint effectively doesn't apply, but this is annoying and messy.

It's already possible to exclude this constraint by modifying constraints in settings.toml, but this is a bit fiddly and in general I don't think users should be modifying constraints (I encourage users to leave this out of their settings files so all the constraints are used by default).

I think the change here to make these parameters optional is more user friendly, as all users need to do now is delete the relevant columns if they don't want to use the constraint for that sector.

Close #667

Type of change

  • New feature (non-breaking change which adds functionality)
  • Optimization (non-breaking, back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (whatever its nature)

Key checklist

  • All tests pass: $ python -m pytest
  • The documentation builds and looks OK: $ python -m sphinx -b html docs docs/build

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@tsmbland tsmbland changed the title Make capacity growth constraints optional Make capacity growth parameters optional Mar 11, 2025
@tsmbland tsmbland requested a review from dalonsoa March 11, 2025 12:00
@tsmbland tsmbland moved this to 👀 In review in MUSE Mar 12, 2025
Copy link
Copy Markdown
Collaborator

@dalonsoa dalonsoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming the solver is happy with np.inf, and it seems it is considering that the tests run, this looks good to me.

May I suggest adding a quick test to check the new functionality?

@tsmbland
Copy link
Copy Markdown
Collaborator Author

Assuming the solver is happy with np.inf, and it seems it is considering that the tests run, this looks good to me.

The solver won't accept np.inf, however (unless the user puts "inf" in the input file, see below), np.inf should never reach the solver

  • if all three parameters are not specified, the constraint isn't constructed (returns None)
  • if one (or two) of the parameters is missing, this will be interpreted as np.inf, but should always be replaced by a finite value in the line b = np.minimum(np.minimum(add_cap, total_cap), growth_cap)

I only just realised while making this PR that "inf" is an accepted value for these parameters, and it will work as intended unless all three parameters are "inf" (then the min operation will return np.inf and it will fail). This is why I haven't mentioned in the documentation that "inf" can be used, so hopefully users won't do this.

@dalonsoa
Copy link
Copy Markdown
Collaborator

Maybe then, in a separate PR, add some validation so if a user gives all inf, there's an error.

@tsmbland tsmbland merged commit 5f3d826 into main Mar 12, 2025
11 of 14 checks passed
@tsmbland tsmbland deleted the optional_growth_constraints branch March 12, 2025 19:42
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in MUSE Mar 12, 2025
@tsmbland tsmbland self-assigned this Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Make MaxCapacityAddition, MaxCapacityGrowth and TotalCapacityLimit optional

2 participants